<%@ Control Language="C#" AutoEventWireup="true" CodeFile="SearchControl.ascx.cs" Inherits="SearchControl" %>
<script src="<%=Session["strHttp"]%>/Jscript/Validation.js"></script>

<script>
    //<![CDATA[

    <%if (IsPostBack)
      {%>

    //commented at 18/06/08 

    //showWorking();   

    //End at 18/06/08

    workingWin.close(); 
      <%} %>
    function selectDistance(obj) {

        var retVal;
        retVal = false;
        //           
        //         
        if (obj.value != 0) {
            //    alert("IN IF");
            if ((trim(document.getElementById('<%=txtCity.ClientID%>').value) != "") && (trim(document.getElementById('<%=txtCity.ClientID%>').value) != "City :")) {
                retVal = true;
                //        alert("Set true");
            }
            else {
                retVal = false;
                //        alert("Set false");
            }



            if (retVal == false) {
                if ((trim(document.getElementById('<%=txtZipCode.ClientID%>').value) != "") && (trim(document.getElementById('<%=txtZipCode.ClientID%>').value) != "Zipcode:")) {
                    retVal = true;
                    //            alert("Set ZIP true");
                }
                else {
                    retVal = false;
                    //            alert("Set ZIP false");
                }
            }

            if (retVal) {
                if (trim(document.getElementById('<%=ddlState.ClientID%>').value) == "0") {
                    alert("Please select a state to utilize Travel Distance feature with city");
                    return false;
                }
            }
            else {
                alert("Please enter a city name or zip code to utilize Travel Distance feature");
                return false;
            }
        }

        return true;
    }

    function checkError() {
        v = selectDistance(document.getElementById('<%=ddlDistance.ClientID%>'))
        if (v) {
            arr = new Array(document.getElementById('<%=ddlCountry.ClientID%>'),
             document.getElementById('<%=ddlState.ClientID%>'),
         document.getElementById('<%=txtCity.ClientID%>'),
        document.getElementById('<%=txtZipCode.ClientID%>'),
        document.getElementById('<%=ddlRating.ClientID%>'),
        document.getElementById('<%=ddlSpeciality.ClientID%>'),
        document.getElementById('<%=ddlSubSpeciality.ClientID%>'),
        document.getElementById('<%=txtLName.ClientID%>'),
        document.getElementById('<%=ddlDistance.ClientID%>'))
            count = 0;
            for (i = 0 ; i < arr.length ; i++) {
                if ((trim(eval(arr[i]).value) != "0") && (trim(eval(arr[i]).value) != "") && (trim(eval(arr[i]).value) != "City :") && (trim(eval(arr[i]).value) != "Zipcode:") && (trim(eval(arr[i]).value) != "Last Name:")) {
                    count++;
                }
            }
            if (count < 2) {
                //THIS TEXT WAS REPLACED WITH THE BELOW ONE : K, 16 DECEMBER 2006
                //alert("Please select atleast 2 conditions for search");
                alert("Please select at least 2 search criteria");
                return false;
            }
            if (chkMinLen(document.getElementById('<%=txtCity.ClientID%>'), 3))
                if (chkMinLen(document.getElementById('<%=txtZipCode.ClientID%>'), 5)) {
                    //showWorking();
                    return true;
                }
                else
                    return false;
            else
                return false;

            //showWorking();
            return true;
        }
        else
            return v;

    }

    //]]>
    function Switch() {
       
        var jobType = document.getElementById('ctl00_MainTable_SearchControl1_ddlDind').value;
        //alert(jobType);
        if (jobType == 'Doctor') {


            document.getElementById('ctl00_MainTable_SearchControl1_ddlDentistSpeciality').style.display = 'none';
            document.getElementById('ctl00_MainTable_SearchControl1_ddlSpeciality').style.display = 'block';
            document.getElementById('ctl00_MainTable_SearchControl1_ddlSubSpeciality').style.display = 'block';
            document.getElementById('ctl00_MainTable_SearchControl1_ddlDentistSubSpeciality').style.display = 'none';
        }
        else if (jobType == 'Dentist') {


            document.getElementById('ctl00_MainTable_SearchControl1_ddlSpeciality').style.display = 'none';
            document.getElementById('ctl00_MainTable_SearchControl1_ddlDentistSpeciality').style.display = 'block';
            document.getElementById('ctl00_MainTable_SearchControl1_ddlSubSpeciality').style.display = 'none';
            document.getElementById('ctl00_MainTable_SearchControl1_ddlDentistSubSpeciality').style.display = 'block';
            
            
        }
    }

</script>


<div class="form-block fl">
    <asp:UpdatePanel ID="UpdatePanel4" runat="server" UpdateMode="Always">
        <ContentTemplate>
            <table width="300" border="0" align="center">
                <tr>
                    <td colspan="3" class="error">
                        <asp:Label runat="server" ID="lblMesg" Text="Please Enter a Valid E-mail address"></asp:Label></td>
                </tr>

                <tr>
                    <td width="101" align="right">COUNTRY</td>
                    <td width="30">&nbsp;</td>
                    <td width="155">
                        <div class="styled-select" style="width: 180px">
                            <asp:DropDownList ID="ddlCountry" runat="server" Style="width: 200px" OnSelectedIndexChanged="ddlCountry_SelectedIndexChanged" AutoPostBack="True">
                            </asp:DropDownList>
                        </div>
                    </td>
                </tr>
               
                <tr>
                    <td width="101" align="right">STATE/PROVINCE</td>
                    <td width="30">&nbsp;</td>
                    <td width="155">
                        <div class="styled-select" style="width: 180px">
                            <asp:DropDownList ID="ddlState" runat="server" Style="width: 200px">
                            </asp:DropDownList>
                        </div>
                    </td>
                </tr>
                
                <tr>
                    <td width="101" align="right">CITY</td>
                    <td width="30">&nbsp;</td>
                    <td width="155">
                        <asp:TextBox ID="txtCity" runat="server" CssClass="design" Style="width: 178px" />
                    </td>
                </tr>
               
                <tr>
                    <td width="101" align="right">ZIP CODE</td>
                    <td width="30">&nbsp;</td>
                    <td width="155">
                        <asp:TextBox ID="txtZipCode" runat="server" CssClass="design" class="mainselection" Style="width: 178px" />

                    </td>
                </tr>
               
                <tr>
                    <td width="101" align="right">FIND</td>
                    <td width="30">&nbsp;</td>
                    <td width="155">
                        <div class="styled-select" style="width: 180px">
                            <asp:DropDownList ID="ddlDind" runat="server" Style="width: 200px" onchange="Switch();">
                                <asp:ListItem>Doctor</asp:ListItem>
                                <asp:ListItem>Dentist</asp:ListItem>
                            </asp:DropDownList>
                        </div>
                    </td>
                </tr>
               
                <tr>
                    <td width="101" align="right">DISTANCE</td>
                    <td width="30">&nbsp;</td>
                    <td width="155">
                        <div class="styled-select" style="width: 180px">
                            <asp:DropDownList ID="ddlDistance" runat="server" Style="width: 200px">
                                <asp:ListItem Value="0">Distance :</asp:ListItem>
                                <asp:ListItem Value="5">5 miles or less</asp:ListItem>
                                <asp:ListItem Value="10">10 miles or less</asp:ListItem>
                                <asp:ListItem Value="25">25 miles or less</asp:ListItem>
                                <asp:ListItem Value="50">50 miles or less</asp:ListItem>
                                <asp:ListItem Value="100">100 miles or less</asp:ListItem>
                            </asp:DropDownList>
                        </div>

                    </td>
                </tr>
              
                <tr>
                    <td width="101" align="right">LAST NAME</td>
                    <td width="30">&nbsp;</td>
                    <td width="155">
                        <asp:TextBox ID="txtLName" runat="Server" CssClass="design" Style="width: 178px"></asp:TextBox></td>
                </tr>
               
                <tr>
                    <td width="101" align="right">SPECIALTY</td>
                    <td width="30">&nbsp;</td>
                    <td width="155">
                        <div class="styled-select" style="width: 180px">
                            <asp:DropDownList ID="ddlSpeciality" runat="server" Style="width: 200px">
                            </asp:DropDownList>
                            <asp:DropDownList ID="ddlDentistSpeciality" runat="server"  Style="width: 200px">
                            </asp:DropDownList>
                        </div>
                    </td>
                </tr>
              
                <tr>
                    <td width="101" align="right">SUB-SPECIALTY</td>
                    <td width="30">&nbsp;</td>
                    <td width="155">
                        <div class="styled-select" style="width: 180px">
                            <asp:DropDownList ID="ddlSubSpeciality" runat="server" Style="width: 200px" EnableViewState="true"></asp:DropDownList>
                            <asp:DropDownList ID="ddlDentistSubSpeciality" runat="server" Style="width: 200px" EnableViewState="true"></asp:DropDownList>
                        </div>
                    </td>
                </tr>
              
                <tr>
                    <td width="101" align="right">ALL RATINGS</td>
                    <td width="30">&nbsp;</td>
                    <td width="155">
                        <div class="styled-select" style="width: 180px">
                            <asp:DropDownList ID="ddlRating" runat="server" Style="width: 200px">
                            </asp:DropDownList>
                        </div>
                    </td>
                </tr>
            
                <tr>
                    <td  align="right" colspan="2"><asp:Button runat="server" ID="btnSearch" CssClass="buttonclass" OnClick="btnSearch_Click" Text="Search" CausesValidation="false" /></td>
                   
                   <td width="155" align="right" style="padding-right:20px;"><a href="<%=Session["strHttp_New"]%>SearchDoctors_adv.aspx" 
                        onmouseover="this.style.color='#FF6600'" 
                        onmouseout="this.style.color='#4B6A88'" ><strong>Advanced Search</strong></a>&nbsp;>>
                        </td>
                </tr>
            </table>
        </ContentTemplate>
    </asp:UpdatePanel>
    <script>    Switch();</script>
</div>



